package classpath

import (
	"path/filepath"
	"io/ioutil"
)

/**
根据目录查找Class，类似于tomcat的class目录
 */
type DirEntry struct {
	absDir string
}

func newDirEntry(path string) *DirEntry {
	absDir, err := filepath.Abs(path)
	if err != nil {
		panic(err) //
	}
	return &DirEntry{absDir}
}

// self 传入对象指针
func (self *DirEntry)readClass(className string) ([]byte, Entry, error) {
	fileName := filepath.Join(self.absDir, className) //根据目录和文件名拼接类文件全路径
	data, err := ioutil.ReadFile(fileName)
	return data, self, err

}

func (self *DirEntry)String() string {
	return self.absDir //返回目录
}
